import axios from 'axios';
import base from './config';
// const baseURL = 'http://localhost:8080/api'; // Adjust the base URL as needed
const baseURL= `${base}/api`

export const fetchAvailablePromotions = async () => {
  const userId = localStorage.getItem('userId'); // Get userId from localStorage
  try {
    const response = await axios.get(`${baseURL}/promotion/active`, {
    //   headers: {
    //     'Authorization': `Bearer ${localStorage.getItem('token')}`, // Include token if needed
    //   },
    //   params: {
    //     userId: userId, // Pass userId as a query parameter
    //   },
    });
    return response.data; // Assuming the response structure is correct
  } catch (error) {
    console.error('获取可参加的活动失败:', error);
    throw error;
  }
};
